<template>
	<view class="page">
		<!-- #ifndef MP-TOUTIAO -->
		<custom-nav-bar title="老鱼商店"></custom-nav-bar>
		<!-- #endif -->
		<!-- {{bannerList}} -->
		<home-swiper :list="bannerList"></home-swiper>

		<view class="theme q-px-sm">
			<a-section title="团宠榜" type="line" class="px-2" titleFontSize="1.25rem">
				<template #right>
					<navigator url="/pages/classify/classify" open-type="reLaunch" class="more">更多……</navigator>
				</template>
			</a-section>
			<view class="grid grid-cols-3 gap-1 px-2">
				<theme-item v-for="item in 商品单项组" :key="item.id" :item="item"></theme-item>
				<theme-item :isMore="true"></theme-item>
			</view>
		</view>
	</view>
</template>

<script setup>
	import { ref, reactive } from 'vue';
	import { onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app"
	import { 查商品, 查轮播图 } from '@/api/api'
	import * as util from '@/amtf/utils'

	import homeSwiper from './home-swiper.vue'
	const bannerList = ref([]);

	const 予轮播 = async () => {
		let res = await 查轮播图();
		bannerList.value = res.data.list;
		// console.log('bannerList.value: ', bannerList.value);
	}
	予轮播();

	const 商品单项组 = reactive([]);
	const 予商品 = async () => {
		const res = await 查商品({
			page: 1,
			pageSize: 5,
		})
		if (res.code === 0) {
			util.数组重予(商品单项组, res.data.list)
			for (let 单项 of 商品单项组) {
				单项.图片 = util.予图片路径(单项.图片)
				单项.图片组 = 单项.图片组.map(item => {
					// console.log('处理路径后图片组item: ', item);
					return util.予图片路径(item)
				})
			}
		} else {
			console.log('出错了 res: ', res);
		}
	}
	予商品();

	//跳转到预览页面
	const goPreview = (id) => {
		uni.setStorageSync("storgClassList", randomList.value);
		uni.navigateTo({
			url: "/pages/preview/preview?id=" + id
		})
	}
</script>

<style lang="scss" scoped>
	.aaa {
		background: transparent;

		.uni-list,
		.uni-list-item {
			background: transparent !important;
		}
	}

	.page {
		.theme {
			.more {
				font-size: 32rpx;
				color: #888;
			}
		}
	}
</style>